home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / editor / blksedtr.lha / BED / Rexx / HuntFile.bed < prev    next >
Text File  |  1996-05-06  |  1KB  |  69 lines

  1. /*
  2. **
  3. ** $VER: HuntFile.bed 1.1 (21.04.96)
  4. **
  5. ** HuntFile.bed - By Gerbert Nuijen
  6. **
  7. ** Hunt the current file under the cursor. Not perfect by far, but it works
  8. ** for simple includes and other simple files in the current dir :)
  9. **
  10. */
  11.  
  12. OPTIONS RESULTS
  13.  
  14. GetChar
  15. IF RESULT="" | RESULT="RESULT" | RESULT= " " THEN DO
  16.    SetStatusBar "Cursor not on a (correct) word!"
  17.    Exit
  18. END
  19.  
  20. break=FALSE
  21.  
  22. DO WHILE break=FALSE
  23.    Getchar
  24.    char = RESULT
  25.    IF char="<" THEN DO
  26.       break=TRUE
  27.       endchar=">"
  28.       MoveRight
  29.    END
  30.    IF char=" " | char="RESULT" THEN DO /* If it is an Return code, RESULT
  31.                                           is given as a RESULT of GetChar */
  32.       break=TRUE
  33.       endchar=" "
  34.       MoveRight
  35.    END
  36.    MoveLeft
  37. END
  38.  
  39. exe=""
  40.  
  41. DO WHILE char ~= endchar
  42.    MoveRight
  43.    GetChar
  44.    char = RESULT
  45.    IF char="RESULT" | char=endchar THEN DO   /* that's for return codes */
  46.       char=endchar
  47.    END
  48.    ELSE DO
  49.       exe = exe || char
  50.    END
  51. END
  52.  
  53. ExistsFile exe
  54.  
  55. IF RESULT = "YES" THEN DO
  56.    OpenDoc exe
  57.    EXIT
  58. END
  59. ELSE DO
  60.    exe = "Include:" || exe
  61.    ExistsFile exe
  62.    IF RESULT = "YES" THEN DO
  63.       OpenDoc exe
  64.    END
  65.    ELSE DO
  66.       SetStatusBar "Can't find file! : " || exe
  67.    END
  68. END
  69.